import {req_delete, req_get, req_post, req_put} from './../cssdrequest';
import {R} from "@/type/dto/R";
import {QtBankVO} from "@/type/vo/QtBankVO";
import {RP} from "@/type/dto/RP";

export async function api_question_bank_list(startDate: string,
                                             endDate: string,
                                             questionName: string,
                                             questionTag: string,
                                             queryType: number|null,
                                             examType: number,
                                             page: number,
                                             limit: number
) {
    const data = await req_get('/question/bank', {
        startDate,
        endDate,
        questionName,
        questionTag,
        queryType,
        examType,
        page,
        limit
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<RP<QtBankVO>>;
}

export async function api_question_bank_delete(deleteId: string) {
    const data = await req_delete('/question/bank', {
        id:deleteId
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

//创建题目
export async function api_question_bank_add(qtVO: QtBankVO) {
    const data = await req_post('/question/bank', qtVO);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

//创建题目
export async function api_question_bank_edit(qtVO: QtBankVO) {
    const data = await req_put('/question/bank', qtVO);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

///获取题目和选项的信息
export async function api_question_bank_all(id: string) {
    const data = await req_get('/question/detail', {
        id
    });
    return JSON.parse(data) as R<QtBankVO>;
}
